package com.csdj.springboottest.mapper;

import com.csdj.springboottest.entity.Config;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * author:cloud
 * date:2021/4/23 0023
 **/
@Mapper
public interface ConfigMapper {

    @Select("select * from config where type = #{type}")
    List<Config> findByType(@Param("type")String type);

    @Select("select * from config where type = #{type} and `key` = #{key} and status = 1")
    Config findConfig(@Param("type")String type,@Param("key")String key);

    @Insert("insert into config(type,`key`,value,`desc`,status) values(#{type},#{key},#{value},#{desc},#{status})")
    int insert(Config config);

    @Update(("update config set value = #{value},`desc`=#{value} where type=#{type} and `key`=#{key}"))
    int update(Config config);
}
